/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package facades;

import entities.CompanyAdquiredProfile;
import entities.CompanyAdquiredProfileFolder;
import entities.CompanyFolder;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author damfercer
 */
@Stateless
public class CompanyAdquiredProfileFolderFacade extends AbstractFacade<CompanyAdquiredProfileFolder> {
    @PersistenceContext(unitName = "ProyectoPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public CompanyAdquiredProfileFolderFacade() {
        super(CompanyAdquiredProfileFolder.class);
    }
    
    public CompanyAdquiredProfileFolder find(CompanyAdquiredProfile companyAdquiredProfile, CompanyFolder folder){
        CompanyAdquiredProfileFolder res=null;
        if(folder != null){
            Query namedQuery=em.createNamedQuery("CompanyAdquiredProfileFolder.findByIdCompanyAdquiredProfileAndFolder");
            namedQuery.setParameter("idCompanyAdquiredProfile", companyAdquiredProfile.getIdCompanyAdquiredProfile());
            namedQuery.setParameter("idCompanyFolder", folder.getIdCompanyFolder());
            List<CompanyAdquiredProfileFolder> companyAdquiredProfileFolders=namedQuery.getResultList();
            if(!companyAdquiredProfileFolders.isEmpty()){
                res=companyAdquiredProfileFolders.get(0);
            }
        }
        return res;
    }
}
